<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-form-item label="姓名" prop="title">
        <el-select v-model="queryParams.accNum" filterable  remote 
        :remote-method="getAccNumList" size="small"
        :loading="selectedloading" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.accNum"
            :label="item.accName"
            :value="item.accNum">
            <span style="float: left">{{ item.accName }}</span>
            <span style="float: right; color: #8492a6; font-size: 13px">{{ item.percode }}</span>
          </el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="证件号" prop="operName">
        <el-input
          v-model="queryParams.percode"
          placeholder="证件号"
          clearable
          style="width: 240px;"
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      
      <el-form-item label="记录时间">
        <el-date-picker
                v-model="queryParams.dateList"
                size="small"
                style="width: 380px"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="datetimerange"
                :default-time="['00:00:00','23:59:59']"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                @change="changeTime"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

      <el-table
        v-loading="loading"
        :data="list"
        style="width: 100%;"
      >
        <el-table-column label="账号" align="center" prop="accNum" :show-overflow-tooltip="true" />
        <el-table-column label="姓名" align="center" prop="accName" :show-overflow-tooltip="true" />
        <el-table-column label="部门" align="center" prop="accDepFullPath" />
        <el-table-column label="证件号" align="center" prop="percode" />
        <el-table-column label="设备名称" align="center" prop="deviceName" />
        <el-table-column label="事件触发类别" align="center" prop="enterType" >
          <template slot-scope="scope">
            <label v-if="scope.row.enterType==0">刷卡</label>
            <label v-if="scope.row.enterType==1">人脸</label>
            <label v-if="scope.row.enterType==2">虹膜</label>
            <label v-if="scope.row.enterType==3">指纹</label>
            <label v-if="scope.row.enterType==4">二维码</label>
          </template>
        </el-table-column>
        <el-table-column label="事件触发名称" align="center" prop="eventName" />
        <el-table-column label="记录时间" align="center" prop="ocurrDateTime" width="180" />
      </el-table>
  
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"  @pagination="originaldata"/>
    </div>
  </template>
  
  <script>
  import { originalData,getAccNumByName} from "@/api/monitor/acsflow";
  
  export default {
    name: "Acsflow",
    data() {
      return {
        // 遮罩层
        loading: true,
        // 总条数
        total: 0,
        // 表格数据
        list: [],
        queryParams: {
          pageNum: 1, //页码
          pageSize: 10, //每页大小
          dateList:[]
        },
        options:[],
        selectedloading:false,
  
      };
    },
    created() {
        this.originaldata();
        var curDate = new Date()
        this.queryParams.dateList=[this.parseTime(new Date(curDate.getTime() - 86400*1000)),this.parseTime(new Date())]
    },
    methods: {
      changeTime(val){
        console.log(val)
      },
      resetQuery(){
        var curDate = new Date()
        this.queryParams={
          pageNum:1,
          pageSize:10,
          dateList:[this.parseTime(new Date(curDate.getTime() - 86400*1000)),this.parseTime(new Date())],
          accName:null,
          percode:null
        }
        this.originaldata()
      },
      getAccNumList(val){
        this.selectedloading=true
        getAccNumByName({accName:val}).then(resp=>{
          this.options = resp.data
          console.log(this.options)
          this.selectedloading=false
        })
      },
      /** 查询门禁流水列表 */
      originaldata()   {
        console.log()
        this.loading = true
        if(this.queryParams.dateList.length>0){
          this.queryParams.startTime = this.queryParams.dateList[0]
          this.queryParams.endTime = this.queryParams.dateList[1]
        }else{
          this.queryParams.startTime = null
          this.queryParams.endTime = null
        }
        originalData(this.queryParams).then((res) => {
          console.log(res);
          this.list = res.data.list;
          this.total = res.data.total;
          this.loading = false;
        });
    },
      /** 搜索按钮操作 */
      handleQuery() {
        this.pageNum = 1;
        this.originaldata();
      },

    }
  };
  </script>
  
  